<?php
/**
 * Created by PhpStorm.
 * User: Liu
 * Date: 2022/12/14
 * Time: 9:20
 */

namespace app\admin\controller;

use app\admin\common\Base;

class Policy extends Base {
    public function policy($id){
        if (is_post()){
            $result = db('policy')
                ->where('id',$id)
                ->update(input('post.'));
            if ($result){
                insert_system_log('修改隐私政策');
                return json(['code' => 'suc', 'msg' => '修改成功']);
            }else {
                return json(['code' => 'err', 'msg' => '系统繁忙，请重试']);
            }
        }
        $info = db('policy')
            ->where('id',$id)
            ->find();
        if ($id == 1){
            $template = 'company/privacy_policy';
        } else {
            $template = 'company/terms_of_service';
        }
        $this->assign('info',$info);
        return $this->fetch($template);
    }
}